﻿@{
    ViewBag.Title = "CustomerInfoDetail";
}
@model CRM.Admin.Contracts.Dto.Customer.CustomerDetailDto
@section head
{
    <link href="~/Content/index.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="@Url.Content("~/ScriptPlugin/WdatePicker/js/WdatePicker.js")"></script>
}
<div id="loadgif" style="width:66px;height:66px;position:fixed;top:50%;left:50%;">
    <img alt="加载中..." src="~/img/uploading.gif" />
</div>
<div class="content">
    <div class="container_up">
        <span>客户信息分析</span>
        <div class="container_title">
            <span></span>客户基本信息
        </div>
        <table class="table table-bordered table-striped">
            <tbody>
                <tr>
                    <td style="width:200px">企业名称</td>
                    <td style="width:200px">@Model.Customer.Name</td>
                    <td style="width:200px">所属行业</td>
                    <td style="width:200px">@Model.Customer.Industry</td>
                    <td style="width:200px">企业规模</td>
                    <td style="width:200px">@Model.Customer.Scale</td>
                </tr>
                <tr>
                    <td>地址</td>
                    <td>@Model.Customer.AddressDescription</td>
                    <td>法人代表</td>
                    <td>@Model.Customer.LegalMan</td>
                    <td>资信状况</td>
                    <td>@Model.Customer.CreditInfo</td>
                </tr>
                <tr>
                    <td>主管业务</td>
                    <td>@Model.Customer.Business</td>
                    <td>与我公司合作状态</td>
                    <td colspan="3">@Model.Customer.CooperationState</td>
                </tr>
                <tr>
                    <td>联系人</td>
                    <td>@Model.LinkMan.Name</td>
                    <td>职务</td>
                    <td>@Model.LinkMan.Job</td>
                    <td>固定电话</td>
                    <td>@Model.LinkMan.Tel</td>
                </tr>
                <tr>
                    <td>手机</td>
                    <td>@Model.LinkMan.Phone</td>
                    <td>E-mail</td>
                    <td>@Model.LinkMan.Email</td>
                    <td>QQ号码</td>
                    <td>@Model.LinkMan.QQnumber</td>
                </tr>
            </tbody>
        </table>
        <div class="container_down">
            <div class="container_title">
                <span></span>客户历年需求的品种结构、数量
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>年份：</label>
                    <select id="needYear">
                        <option value="0"></option>
                        @for (int i = 2010; i < 2023; i++)
                        {
                            <option value="@i">@i</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" value="查询" class="btn" onclick="selectNeed()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>年份</th>
                        <th>历年需求品种</th>
                        <th>历年用量</th>
                        <th>材质</th>
                        <th>规格</th>
                    </tr>
                </thead>
                <tbody id="need">
                    @*@if (Model.VarietyList.Count < 1)
                        {
                            <tr><td colspan="5">无数据</td></tr>
                        }
                        else {
                            foreach (var item in Model.VarietyList)
                            {
                                <tr>
                                    <td>@item.ParticularYear</td>
                                    <td>@item.BreedName</td>
                                    <td>@item.NowNeedWeight</td>
                                    <td>@item.MaterialMade</td>
                                    <td>@item.MaterialSpecs</td>
                                </tr>
                            }
                        }*@
                </tbody>
            </table>

            <div class="container_title">
                <span></span>客户预计需求的品种结构、数量
            </div>

            <table class="table table-title">
                <thead>
                    <tr>
                        <th>年份</th>
                        <th>当年需求量预计(吨)</th>
                        <th>明年需求量预计(吨)</th>
                        <th>材质</th>
                        <th>规格</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>@Model.Variety.ParticularYear</td>
                        <td>@Model.Variety.YearNeedProfiles</td>
                        <td>@Model.Variety.NextYearNeedProfiles</td>
                        <td>@Model.Variety.MaterialMade</td>
                        <td>@Model.Variety.MaterialSpecs</td>
                    </tr>
                </tbody>
            </table>

            <div class="container_title">
                <span></span>客户攀钢对顾客需求品种的可供量及供货量
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>年份：</label>
                    <select id="suppYear">
                        <option value="0"></option>
                        @for (int i = 2010; i < 2023; i++)
                        {
                            <option value="@i">@i</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" value="查询" class="btn" onclick="selectSupp()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>年份</th>
                        <th>历年攀钢可供应量(吨)</th>
                        <th>历年攀钢供货量(吨)</th>
                        <th>材质</th>
                        <th>规格</th>
                    </tr>
                </thead>
                <tbody id="supp">
                    @*@if (Model.VarietyList.Count < 1)
                        {
                            <tr><td colspan="5">无数据</td></tr>
                        }
                        else {
                            foreach (var item in Model.VarietyList)
                            {
                                <tr>
                                    <td>@item.ParticularYear</td>
                                    <td>@item.PGCoverWeight </td>
                                    <td>@item.PGAlreadySupplyWeight</td>
                                    <td>@item.MaterialMade</td>
                                    <td>@item.MaterialSpecs</td>
                                </tr>
                            }
                        }*@
                </tbody>
            </table>

            <div class="container_title">
                <span></span>客户新产品需求及攀钢新产品开发建议
            </div>
            <table class="table table-bordered table-striped">
                <tbody>
                    <tr>
                        <td style="width:251px;">客户新产品需求</td>
                        <td>@Model.Variety.NewProductProfiles</td>
                    </tr>
                    <tr>
                        <td style="width: 251px;">攀钢新产品开发建议</td>
                        <td>@Model.Variety.NewUserProfiles</td>
                    </tr>
                </tbody>
            </table>
            <div class="container_title">
                <span></span>客户未来发展规划
            </div>
            <table class="table table-bordered table-striped">
                <tbody>
                    <tr>
                        <td style="width: 251px;">客户未来发展规划</td>
                        <td>@Model.Variety.NextNeedProfiles</td>
                    </tr>
                </tbody>
            </table>
            <div class="container_title">
                <span></span>客户要求(技术、质量、交货期)及攀钢不能供货原因
            </div>
            <table class="table table-bordered table-striped">
                <tbody>
                    <tr>
                        <td style="width: 251px;">客户要求(技术、质量、交货期)</td>
                        <td>@Model.Variety.QualityProfiles</td>
                    </tr>
                    <tr>
                        <td style="width: 251px;">攀钢不能供货原因</td>
                        <td>@Model.Variety.NoCooperateProfiles</td>
                    </tr>
                </tbody>
            </table>
            <div class="container_title">
                <span></span>销售可行性分析及要实现供货的营销策略、设备新上或改造等
            </div>
            <table class="table table-bordered table-striped">
                <tbody>
                    <tr>
                        <td style="width: 251px;">销售可行性分析</td>
                        <td>@Model.Variety.SaleFeasibility</td>
                    </tr>
                    <tr>
                        <td style="width: 251px;">供货的营销策略、设备新上或改造</td>
                        <td>@Model.Variety.MarketingStrategy</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="container_down">
            <span>攀钢销售系统客户业务分析</span>
            <a>顾客订单分析</a>
            <div class="container_title">
                <span></span>综合分析
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>时间类型：</label>
                    <select id="orderType">
                        <option value="资源期" selected="selected">资源期</option>
                        <option value="交货期">交货期</option>
                        <option value="下发时间">下发时间</option>
                    </select>
                </div>
                <div class="selectTime">
                    <label>时间区间：</label>
                    @*<input type="text"  placeholder="时间格式2016-07" id="orderBegintime"/><span></span>*@
                    <input type="text" id="orderBegintime" name="orderBegintime" onClick="WdatePicker({dateFmt:'yyyyMM'})" value="@DateTime.Now.ToString("yyyyMM")" readonly="readonly" class="p-icon-date p-icon-right" />
                    <label style="margin:0 20px;"> 至 </label>
                    @*<input type="text" placeholder="时间格式2016-07" id="orderEndtime"/><span style="right:37px;"></span>*@
                    <input type="text" id="orderEndtime" name="orderEndtime" onClick="WdatePicker({dateFmt:'yyyyMM'})" value="@DateTime.Now.ToString("yyyyMM")" readonly="readonly" class="p-icon-date p-icon-right" />
                </div>
                <div class="selectBox">
                    <label>产品大类：</label>
                    <select id="orderProd">
                        <option value=""></option>
                        @foreach (var item in ViewBag.prod)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <label>销售品种：</label>
                    <select id="orderSala">
                        <option value=""></option>
                        @foreach (var item in ViewBag.sala)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <label>付款方式：</label>
                    <select id="mode">
                        <option value=""></option>
                        @foreach (var item in ViewBag.mode)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="searchbox">
                    <input type="button" value="查询" class="btn" onclick="selectOrder()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>销售品种</th>
                        <th>订货量(吨)</th>
                        <th>订货单价(元)</th>
                        <th>订货总金额(元)</th>
                        <th>交货量(吨)</th>
                        <th>结算量(吨)</th>
                        <th>结算单价(元)</th>
                        <th>结算总金额(元)</th>
                        <th>上期结算价(元)</th>
                        <th>去年周期结算价(元)</th>
                    </tr>
                </thead>
                <tbody id="order"></tbody>
            </table>
            <div class="container_title">
                <span></span>合同兑现率分析
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>时间类型：</label>
                    <select id="htType">
                        <option value=""></option>
                        <option value="资源期" selected="selected">资源期</option>
                        <option value="交货期">交货期</option>
                        <option value="下发时间">下发时间</option>
                    </select>
                </div>
                <div class="selectTime">
                    <label>时间区间：</label>
                    @*<input type="text" id="htbegintime" placeholder="时间格式2016-07"/><span></span>*@
                    <input type="text" id="htbegintime" name="htbegintime" onClick="WdatePicker({dateFmt:'yyyyMM'})" value="@DateTime.Now.ToString("yyyyMM")" readonly="readonly" class="p-icon-date p-icon-right" />
                    <label style="margin:0 20px;"> 至 </label>
                    @*<input type="text"id="htendtime" placeholder="时间格式2016-07"/><span style="right:37px;"></span>*@
                    <input type="text" id="htendtime" name="htendtime" onClick="WdatePicker({dateFmt:'yyyyMM'})" value="@DateTime.Now.ToString("yyyyMM")" readonly="readonly" class="p-icon-date p-icon-right" />
                </div>
                <div class="selectBox">
                    <label>产品大类：</label>
                    <select id="htProdName">
                        <option value=""></option>
                        @foreach (var item in ViewBag.prod)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <label>销售品种：</label>
                    <select id="htSalaName">
                        <option value=""></option>
                        @foreach (var item in ViewBag.sala)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" value="查询" class="btn" onclick="selectht()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>销售品种</th>
                        <th>合同兑现率(按交货量)</th>
                        <th>合同兑现率(按结算量)</th>
                    </tr>
                </thead>
                <tbody id="ht">
                    @*@if (Model.Order.Count < 1)
                        {
                            <tr><td colspan="3">无数据</td></tr>
                        }
                        else
                        {
                            foreach (var item in Model.Order)
                            {
                                <tr>
                                    <td>@item.SalesVariety</td>
                                    <td>@string.Format("{0}",Math.Round(item.DeliveryVolume / item.OrderQuantity *100, 2)) %</td>
                                    <td>@string.Format("{0}",Math.Round(item.SettlementAmount / item.DeliveryVolume *100, 2)) %</td>
                                </tr>
                            }
                        }*@

                </tbody>
            </table>

            <div class="container_title">
                <span></span>客户协议完成情况分析
            </div>
            <form class="SearchBar">
                @*<div class="selectTime">
                        <label>时间区间：</label>
                        <input type="text"  id="begintime"/><span></span>
                        <label style="margin:0 20px;"> 至 </label>
                        <input type="text"  id="endtime"/><span style="right:37px;"></span>
                    </div>*@
                <div class="selectBox">
                    <label>销售品种：</label>
                    <select id="agrProd">
                        <option value=""></option>
                        @foreach (var item in ViewBag.sala)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" class="btn" value="查询" onclick="agrselect()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>销售品种</th>
                        <th>年份-月份</th>
                        <th>协议量(吨)</th>
                        <th>完成量(吨)</th>
                    </tr>
                </thead>
                <tbody id="agr">
                    @*@if (Model.CustomerAgreement.Count < 1)
                        {
                            <tr><td colspan="4"></td></tr>
                        }
                        else {
                            foreach (var item in Model.CustomerAgreement)
                            {
                                <tr>
                                    <td>@item.ProdName</td>
                                    <td>@item.Year-@item.moth</td>
                                    <td>@item.ProtocolQuantity </td>
                                    <td>@item.CompletionQuantity</td>
                                </tr>
                            }
                            <tr class="total">
                                <td class="total-title">合计</td>
                                <td style="color: #333;font-weight: bold;">-- --</td>
                                <td>@Model.CustomerAgreement.Sum(a=>a.ProtocolQuantity)</td>
                                <td>@Model.CustomerAgreement.Sum(a=>a.CompletionQuantity)</td>
                            </tr>
                        }*@


                </tbody>
            </table>
            <a>客户订单收发存分析</a>
            <div class="container_title">
                <span></span>客户非直发订单收发存分析
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>产品大类：</label>
                    <select id="stockProd">
                        <option value=""></option>
                        @foreach (var item in ViewBag.prod)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <label>销售品种：</label>
                    <select id="stockSala">
                        <option value=""></option>
                        @foreach (var item in ViewBag.sala)
                        {
                            <option value="@item">@item</option>
                        }

                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" value="查询" class="btn" onclick="selectstcok()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>销售品种</th>
                        <th>入库量(吨)</th>
                        <th>出库量(吨)</th>
                        <th>库存量(吨) </th>
                    </tr>
                </thead>
                <tbody id="stock">
                    @*@if (Model.OrderTransmitReceive.Count < 1)
                        {
                            <tr><td colspan="4">无数据</td></tr>
                        }
                        else
                        {
                            foreach (var item in Model.OrderTransmitReceive)
                            {
                                <tr>
                                    <td>@item.SalesVariety</td>
                                    <td>@item.ScheduledReceipt</td>
                                    <td>@item.OutgoingQuantity</td>
                                    <td>@item.InventoryQuantity</td>
                                </tr>
                            }
                            <tr class="total">
                                <td class="total-title">合计</td>
                                <td>@Model.OrderTransmitReceive.Sum(a => a.ScheduledReceipt)</td>
                                <td>@Model.OrderTransmitReceive.Sum(a => a.OutgoingQuantity)</td>
                                <td>@Model.OrderTransmitReceive.Sum(a => a.InventoryQuantity)</td>
                            </tr>
                        }*@


                </tbody>
            </table>
            <div class="container_title">
                <span></span>库龄分析
            </div>
            <form class="SearchBar">
                <div class="selectBox">
                    <label>产品大类：</label>
                    <select id="ageProd">
                        <option value=""></option>
                        @foreach (var item in ViewBag.prod)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <label>销售品种：</label>
                    <select id="ageSala">
                        <option value=""></option>
                        @foreach (var item in ViewBag.sala)
                        {
                            <option value="@item">@item</option>
                        }
                    </select>
                </div>
                <div class="selectBox">
                    <input type="button" value="查询" class="btn" onclick="selectage()" />
                </div>
            </form>
            <table class="table table-title">
                <thead>
                    <tr>
                        <th>销售品种</th>
                        <th>30天以内(吨)</th>
                        <th>31天到61天(吨)</th>
                        <th>62天到92天(吨)</th>
                        <th>93天到182天(吨)</th>
                        <th>183天到365天(吨)</th>
                        <th>365天以上(吨)</th>
                        <th>库存总量</th>
                    </tr>
                </thead>
                <tbody id="age">
                    @*@if (Model.OldLisbrary.Count < 1)
                        {
                            <tr><td colspan="8">无数据</td></tr>
                        }
                        else {
                            foreach (var item in Model.OldLisbrary)
                            {
                                <tr>
                                    <td>热轧普碳</td>
                                    <td>@item.SaleProdName</td>
                                    <td>@item.ReportDate</td>
                                    <td>@item.KcWt</td>
                                    <td>90吨</td>
                                    <td>90吨</td>
                                    <td>90吨</td>
                                    <td>540吨</td>
                                </tr>
                            }
                        }

                        <tr class="total">
                            <td class="total-title">合计</td>
                            <td>180吨</td>
                            <td>180吨</td>
                            <td>180吨</td>
                            <td>180吨</td>
                            <td>180吨</td>
                            <td>180吨</td>
                            <td >1080吨</td>
                        </tr>*@
                </tbody>
            </table>
        </div>
    </div>
</div>
@section foot{
    <script type="text/javascript">
        function SaveData(index) {
            parent.K.layer.close(index);
        };
        $(function () {
            selectstcok();
            agrselect();
            selectht();
            selectage();
            selectOrder();
            selectNeed();
            selectSupp();
        });
        //需求量
        function selectNeed()
        {
            console.log(1)
            var year=$("#needYear").val();
            $.get('/Customer/CustomerInfo/GetVarietyYear?CustomerId=@Model.Customer.Id',{Year:year},function(result){
                $("#need").empty();
                if(result.length<1)
                {
                    var tr="<tr><td colspan='5'>无数据</td></tr>";
                    $("#need").append(tr);
                }
                $(result).each(function () {
                    if (this.BreedName==null)
                    {
                        this.BreedName = "";
                    }
                    var tr="<tr><td>"+this.ParticularYear+"</td><td>"+this.BreedName+"</td><td>"+this.NowNeedWeight+"</td><td>"+this.MaterialMade+"</td><td>"+this.MaterialSpecs+"</td></tr>";
                    $("#need").append(tr);
                });
            });
        }
        //供应量及可供量
        function selectSupp()
        {
            var year=$("#suppYear").val();
            $.get('/Customer/CustomerInfo/GetVarietyYear?CustomerId=@Model.Customer.Id',{Year:year},function(result){
                $("#supp").empty();
                if(result.length<1)
                {
                    var tr="<tr><td colspan='5'>无数据</td></tr>";
                    $("#supp").append(tr);
                }
                $(result).each(function(){
                    var tr="<tr><td>"+this.ParticularYear+"</td><td>"+this.PGFCoverWeight+"</td><td>"+this.PGFAlreadySupplyWeight+"</td><td>"+this.MaterialMade+"</td><td>"+this.MaterialSpecs+"</td></tr>";
                    $("#supp").append(tr);
                });
            });
        }
        //查询顾客订单收发存
        function selectstcok() {
            var prod = $("#stockProd").val();
            var sala=$("#stockSala").val()
            $.get('/Customer/CustomerInfo/GetOrderTransmitReceive', { prodName: prod, salaName: sala,salaNum:'@Model.Customer.SaleSysCode' }, function (result) {
                var sr = 0;
                var qq = 0;
                var iq = 0;
                $("#stock").empty();
                if(result.length<1){
                    var  tr="<tr><td colspan='4'>无数据</td></tr>";
                    $("#stock").append(tr);
                }
                $(result).each(function () {
                    sr += this.ScheduledReceipt;
                    qq += this.OutgoingQuantity
                    iq += this.InventoryQuantity;
                    var tr= "<tr><td>" + this.SalesVariety + "</td><td>" + this.ScheduledReceipt + "</td>\
                            <td>" + this.OutgoingQuantity + "</td><td>" +this.InventoryQuantity + "</td></tr>"

                    $("#stock").append(tr);
                });
                if(result.length>0){
                    sr=sr.toFixed(2);
                    qq=qq.toFixed(2);
                    iq=iq.toFixed(2);
                    $("#stock").append("<tr class='total'><td class='total-title'>合计</td><td>"+sr+"</td><td>"+qq+"</td><td>"+iq+"</td></tr>");
                }

            });
        }
        //客户协议
        function agrselect()
        {
            var begin=$("#begintime").val();
            var endtime=$("#endtime").val();
            var agrprod=$("#agrProd").val();
            $.get('/Customer/CustomerInfo/GetCustomerAgreement?CustomerId=@Model.Customer.Id',
                {begintime:begin,endtime:endtime,prodName:agrprod},function(result){
                    var cq=0;
                    var pq=0;
                    $("#agr").empty();
                    if(result.length<1)
                    {
                        var tr="<tr><td colspan='4'>无数据</td></tr>";
                        $("#agr").append(tr);
                    }else{
                        $(result).each(function(){
                            pq+=this.ProtocolQuantity ;
                            cq+=this.CompletionQuantity;
                            var tr="<tr><td>"+this.ProdName+"</td><td>"+this.Year+"-"+this.moth+"</td>\
                           <td>"+this.ProtocolQuantity +"</td><td>"+this.CompletionQuantity+"</td></tr>";
                            $("#agr").append(tr);
                        });
                        $("#agr").append("<tr class='total'><td class='total-title'>合计</td><td>-- --</td><td>"+cq+"</td><td>"+pq+"</td></tr>");
                    }
                });
        }
        //顾客订单分析
        function selectOrder()
        {
            $("#loadgif").show(); 
            var type=$("#orderType").val();
            var begtime=$("#orderBegintime").val();
            var endtime=$("#orderEndtime").val();
            var prod=$("#orderProd").val();
            var sala=$("#orderSala").val();
            var mode=$("#mode").val();
            $.get('/Customer/CustomerInfo/GetCustomerOrder',{timeType:type,beginTime:begtime,endTime:endtime,prodName:prod,salaName:sala,salaNum:'@Model.Customer.SaleSysCode',modeName:mode}
            ,function(result){
                $("#order").empty();
                if(result.length<1)
                {
                    $("#order").append("<tr><td colspan='10'>无数据</td></tr>");
                }else{
                    var oqcount=0;
                    var opcount=0;
                    var opccount=0;
                    var dvcount=0;
                    var slacount=0;
                    var slpcount=0;
                    var spccount=0;
                    var pscount=0;
                    var lpcount=0;
                    $(result).each(function(){
                        var prevPrivce=this.PreviousSettlemenPrivce/this.PreviousAmountCount;
                        var prevYear=this.LastPeriodPrivce/this.LastPeriodAmcountCount;
                        if(isNaN(prevPrivce))
                        {
                            prevPrivce=0.00;
                        }
                        if(isNaN(prevYear))
                        {
                            prevYear=0.00;
                        }
                        oqcount+=this.OrderQuantity;
                        opcount+=this.OrderPrice;
                        opccount+=this.OrderPrivceCount;
                        dvcount+=this.DeliveryVolume;
                        slacount+=this.SettlementAmount;
                        slpcount+=this.SettlementPrivce;
                        spccount+=this.SettlementPrivceCount;
                        pscount+=prevPrivce;
                        lpcount+=prevYear;
                        var tr="<tr><td>"+this.SalesVariety+"</td><td>"+this.OrderQuantity+"</td><td>"+this.OrderPrice+"\
                        </td><td>"+this.OrderPrivceCount+"</td><td>"+this.DeliveryVolume+"</td><td>"+this.SettlementAmount+"\
                        </td><td>"+this.SettlementPrivce+"</td><td>"+this.SettlementPrivceCount+"</td><td>"+prevPrivce.toFixed(2)+"</td><td>"+prevYear.toFixed(2)+"</td></tr>";
                        $("#order").append(tr);
                    });
                    var tr="<tr class='total'><td  class='total-title'>合计</td><td>"+oqcount.toFixed(2)+"</td><td>"+opcount.toFixed(2)+"</td><td>"+opccount.toFixed(2)+"\
                        </td><td>"+dvcount.toFixed(2)+"</td><td>"+slacount.toFixed(2)+"</td><td>"+slpcount.toFixed(2)+"</td><td>"+spccount.toFixed(2)+"</td><td>"+pscount.toFixed(2)+"</td><td>"+lpcount.toFixed(2)+"</td></tr>";
                    $("#order").append(tr);                  
                }
                $("#loadgif").hide();

            });
        }
        //合同兑换率
        function selectht()
        {
            var type=$("#htType").val();
            var begtime=$("#htbegintime").val();
            var endtime=$("#htendtime").val();
            var prod=$("#htProdName").val();
            var sala=$("#htSalaName").val();
            $.get('/Customer/CustomerInfo/GetOrder',{timeType:type,beginTime:begtime,endTime:endtime,prodName:prod,salaName:sala,salaNum:'@Model.Customer.SaleSysCode'}
            ,function(result){
                $("#ht").empty();

                var dv=0;
                var oq=0;
                var sa=0;
                if(result.length<1)
                {
                    $("#ht").append("<tr><td colspan='3'>无数据</td></tr>");
                }else{
                    $(result).each(function(){
                        dv+=this.DeliveryVolume;
                        oq+=this.OrderQuantity;
                        sa+=this.SettlementAmount;
                        var dq=(this.DeliveryVolume/this.OrderQuantity*100).toFixed(2);
                        var sq=(this.SettlementAmount/this.DeliveryVolume*100).toFixed(2);
                        if(isNaN(dq)){
                            dq="0.00";
                        }
                        if(isNaN(sq))
                        {
                            sq="0.00";
                        }
                        var tr="<tr><td>"+this.SalesVariety+"</td><td>"+dq+"%</td><td>"+sq+"%</td></tr>";
                        $("#ht").append(tr);
                    });
                    var dqcount=(dv/oq*100).toFixed(2);
                    var sqcount=(sa/dv*100).toFixed(2);
                    if(isNaN(dqcount))
                    {
                        dqcount="0.00";
                    }
                    if(isNaN(sqcount))
                    {
                        sqcount="0.00";
                    }
                    var tr="<tr class='total'><td class='total-title'>合计</td><td>"+dqcount+"%</td><td>"+sqcount+"%</td></tr>";
                    $("#ht").append(tr);
                }
            });
        }
        //库龄分析
        function selectage()
        {
            var prod=$("#ageProd").val();
            var sala=$("#ageSala").val();
            $.get('/Customer/CustomerInfo/GetOldlibrary',{prodName:prod,salaName:sala,salaNum:'@Model.Customer.SaleSysCode'},function(result){
                $("#age").empty();
                var wt30=0;
                var wt30_60=0;
                var wt60_90=0;
                var wt90_180=0;
                var wt180_365=0;
                var wt365=0;
                var wtcount=0;
                if(result.length<1)
                {
                    var tr="<tr><td colspan='8'>无数据</td></tr>";
                    $("#age").append(tr);
                }else{
                    $(result).each(function(){
                        wt30+=this.KcWt30;
                        wt30_60+=this.KcWt31_61;
                        wt60_90+=this.KcWt62_92;
                        wt90_180+=this.KcWt93_182;
                        wt180_365+=this.KcWt183_365;
                        wt365+=this.KcWt365;
                        wtcount+=this.kwCount;
                        var tr="<tr><td>"+this.SaleProdName+"</td><td>"+this.KcWt30+"</td><td>"+this.KcWt31_61+"\
                            </td><td>"+this.KcWt62_92+"</td><td>"+this.KcWt93_182+"</td><td>"+this.KcWt183_365+"\
                            </td><td>"+this.KcWt365+"</td><td>"+this.kwCount+"</td></tr>";
                        $("#age").append(tr);
                    });
                    var tr="<tr class='total'><td class='total-title'>合计</td><td>"+wt30.toFixed(2)+"</td><td>"+wt30_60.toFixed(2)+"</td><td>"+ wt60_90.toFixed(2)+"</td><td>"+ wt90_180.toFixed(2)+"</td><td>"+wt180_365.toFixed(2)+"\
                        </td><td>"+ wt365.toFixed(2)+"</td><td>"+wtcount.toFixed(2)+"</td></tr>";
                    $("#age").append(tr);
                }
            });
        }
    </script>
}



